// 一、导入模块
// 1.1 路由模块
import VueRouter from "vue-router"
// 1.2 导入tabbar(切换栏)中的组件
import Home from "./components/tabbars/Home.vue"
import Member from "./components/tabbars/Member.vue"
import Cart from "./components/tabbars/Cart.vue"
import Search from "./components/tabbars/Search.vue"
// 1.3 导入news(新闻资讯)中的组件
import NewsList from "./components/news/NewsList.vue"
import NewsInfo from "./components/news/NewsInfo.vue"
// 1.4 导入photos(图片分享)中的组件
import PhotoList from "./components/photos/PhotoList.vue"
import PhotoInfo from "./components/photos/PhotoInfo.vue"
// 1.5 导入goods(商品购买)中的组件
import GoodsList from "./components/goods/GoodsList.vue"
import GoodsInfo from "./components/goods/GoodsInfo.vue"
import GoodsDesc from "./components/goods/GoodsDesc.vue"
import GoodsComment from "./components/goods/GoodsComment.vue"

// 二、创建路对象
const router = new VueRouter({
  routes: [
    // 2.1 tabbar相关的路由规则
    { path: "/", redirect: "/home" }, // 首页路由重定向
    { path: "/home", component: Home },
    { path: "/member", component: Member },
    { path: "/cart", component: Cart },
    { path: "/search", component: Search },

    // 2.2 news相关的路由规则
    { path: "/home/newslist", component: NewsList }, // 新闻列表
    { path: "/home/newsinfo/:id", component: NewsInfo, props: true }, // 新闻详情 启用props来接收路由参数

    // 2.3 图片分享相关路由
    { path: "/home/photolist", component: PhotoList },
    { path: "/home/photoinfo/:id", component: PhotoInfo, props: true },

    // 2.4 商品购买的相关路由
    { path: "/home/goodslist", component: GoodsList },
    { path: "/home/goodsinfo/:id", component: GoodsInfo, props: true },
    { path: "/home/goodsdesc/:id", component: GoodsDesc, props: true },
    {
      path: "/home/goodscomment/:id",
      component: GoodsComment,
      props: true,
      name: "gcmt",
    },
  ],
  // 被激活的类名(高亮)
  linkActiveClass: "mui-active",
})

// 三、导出路由对象
export default router
